//
//  refactoring.m
//  releaseInterface
//
//  Created by Gamefire on 16/4/14.
//  Copyright © 2016年 Gamefire. All rights reserved.
//

#import "refactoring.h"
#define  UIColorRGBA(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)]

#define kWindowWidth                        ([[UIScreen mainScreen] bounds].size.width)

#define kWindowHeight                       ([[UIScreen mainScreen] bounds].size.height)
@interface  refactoring(){

    UIButton *btn2;
    UILabel *unallowlabel;
    UILabel *allowlabel;
    UIButton *allowBtn;
    UIButton *unallowBtn;
}

@end
@implementation refactoring
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self setBackgroundColor:[UIColor whiteColor]];
        UILabel *refactoringlabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0, kWindowWidth,20 )];
        [refactoringlabel setBackgroundColor:UIColorRGBA(237, 237, 237, 1)];
        [refactoringlabel setText:@"   重构权限"];
        [refactoringlabel setTextColor:UIColorRGBA(102, 102, 102, 1)];
        [refactoringlabel setFont:[UIFont systemFontOfSize:11.0]];
        [self addSubview:refactoringlabel];
        
        allowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [allowBtn setFrame:CGRectMake(15, 30, self.bounds.size.height - 32, self.bounds.size.height - 32)];
        [allowBtn.layer setCornerRadius:(self.bounds.size.height - 32)/2];
        [allowBtn addTarget:self action:@selector(SelectedEvent) forControlEvents:UIControlEventTouchUpInside];
        [allowBtn setTag:101];
        [self addSubview:allowBtn];
        
        allowlabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(allowBtn.frame)-5, self.bounds.size.height / 2.0 + 4, 60, 16)];
        [allowlabel setTextColor:UIColorRGBA(153, 153, 153, 1)];
        [allowlabel setText:@"允许重构"];
        [allowlabel setFont:[UIFont systemFontOfSize:14.0]];
        [self addSubview:allowlabel];
        
        unallowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [unallowBtn setFrame:CGRectMake(self.bounds.size.height - 32 + 105, 30, self.bounds.size.height - 32, self.bounds.size.height - 32)];
        [unallowBtn.layer setCornerRadius:(self.bounds.size.height - 32)/2];
        [unallowBtn addTarget:self action:@selector(unSelectedEvent) forControlEvents:UIControlEventTouchUpInside];
        [unallowBtn setTag:102];
        [self addSubview:unallowBtn];
        UIImage *image = nil;
        image = [UIImage imageNamed:@"weixuanze"];
        [allowBtn setImage:image forState:UIControlStateNormal];
        [unallowBtn setImage:image forState:UIControlStateNormal];
        
        
        
        unallowlabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(unallowBtn.frame)-5,  self.bounds.size.height / 2.0 + 4, 60, 16)];
        [unallowlabel setText:@"不允许"];
        [unallowlabel setTextColor:UIColorRGBA(153, 153, 153, 1)];
        [unallowlabel setFont:[UIFont systemFontOfSize:14.0]];
        [self addSubview:unallowlabel];
    }
    return self;
}



- (void)SelectedEvent
{
    [unallowBtn setImage:[UIImage imageNamed:@"weixuanze"] forState:UIControlStateNormal];
    [allowBtn setImage:[UIImage imageNamed:@"Arrow"] forState:UIControlStateNormal];
    [allowlabel setTextColor:[UIColor blackColor]];
    [unallowlabel setTextColor:UIColorRGBA(153, 153, 153, 1)];
    
    [_MrefactoringDelegate changeReEdite:1];
}
- (void)unSelectedEvent
{
    [allowBtn setImage:[UIImage imageNamed:@"weixuanze"] forState:UIControlStateNormal];
    [unallowBtn setImage:[UIImage imageNamed:@"Arrow"] forState:UIControlStateNormal];
    [unallowlabel setTextColor:[UIColor blackColor]];
    [allowlabel setTextColor:UIColorRGBA(153, 153, 153, 1)];
    [_MrefactoringDelegate changeReEdite:0];
}
@end
